void waypt_flush(queue *);
void waypt_flush_all(void);
unsigned int waypt_count(void);
+void set_waypt_count(unsigned int nc);
void free_gpx_extras (xml_tag * tag);
void xcsv_setup_internal_style(const char *style_buf);
void xcsv_read_internal_style(const char *style_buf);
#define QUEUE_LAST(head) (head)->prev
#define QUEUE_EMPTY (head)->next == head
#define QUEUE_MOVE(newhead,oldhead) \
- (newhead)->next = (oldhead)->next; \
- (newhead)->prev = (oldhead)->prev; \
- (newhead)->next->prev = (newhead); \
- (newhead)->prev->next = (newhead); \
+ if ( (oldhead)->next == (oldhead) ) {\
+ (newhead)->next = (newhead)->prev = (newhead); \
+ } \
+ else { \
+ (newhead)->next = (oldhead)->next; \
+ (newhead)->prev = (oldhead)->prev; \
+ (newhead)->next->prev = (newhead); \
+ (newhead)->prev->next = (newhead); \
+ } \
(oldhead)->next = (oldhead)->prev = (oldhead)
#define ENQUEUE_TAIL(listhead, element) \
struct stack_elt {
queue waypts;
+ unsigned int waypt_ct;
struct stack_elt *next;
} *stack = NULL;
queue *tmp = NULL;
queue tmp_queue;
waypoint *wpt_tmp;
+ unsigned int tmp_count;
if ( opt_push ) {
tmp_elt = (struct stack_elt *)xmalloc(sizeof(struct stack_elt));
QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head);
+ tmp_elt->waypt_ct = waypt_count();
+ set_waypt_count(0);
tmp_elt->next = stack;
stack = tmp_elt;
if ( opt_copy ) {
else {
waypt_flush( &waypt_head );
QUEUE_MOVE(&(waypt_head), &(stack->waypts) );
+ set_waypt_count(stack->waypt_ct);
}
stack = tmp_elt->next;
xfree( tmp_elt );
QUEUE_MOVE(&tmp_queue, &(tmp_elt->waypts) );
QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head );
QUEUE_MOVE(&waypt_head, &tmp_queue );
+
+ tmp_count = waypt_count();
+ set_waypt_count( tmp_elt->waypt_ct );
+ tmp_elt->waypt_ct = tmp_count;
}
}
return waypt_ct;
}
+void
+set_waypt_count(unsigned int nc)
+{
+ waypt_ct = nc;
+}
+
void
waypt_disp(const waypoint *wpt)
{